/*
 * @Descripttion:
 * @version: 1.0.0
 * @Author: lai_hq@qq.com
 * @Date: 2022-08-05 14:18:22
 * @LastEditors: lai_hq@qq.com
 * @LastEditTime: 2022-08-05 15:22:36
 */
import SecureLS from 'secure-ls'
/**
 * @description: 设置缓存压缩加密
 */
export function useStorage(options = { encodingType: 'aes', encryptionSecret: 'yide-monitoring-system-manage' }) {
    const ls = new SecureLS(options)
    return {
        getItem: (key: string) => ls.get(key),
        setItem: (key: string, value: any) => ls.set(key, value),
        removeItem: (key: string) => ls.remove(key),
        removeAll: () => ls.removeAll()
    }
}

/**
 * @description: 处理token
 */
export function useToken() {
    const key = `Access-Token`
    const { getItem, setItem, removeItem } = useStorage()
    return {
        getToken() {
            return getItem(key)
        },
        setToken(token: string) {
            return setItem(key, token)
        },
        removeToken() {
            return removeItem(key)
        }
    }
}

export function getCurrentUser() {}
